﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YmtAuth.Domain.EventHistory;
using YmtAuth.Domain.Repository;
using YmtSystem.CrossCutting;
using YmtSystem.Infrastructure.EventBusService;

namespace YmtAuth.EventHandler
{
    public class YmtUserPasswordChangeEventHandler : IEventSubscriber<YmtUserPasswordChangeEvent>
    {
        public void Error(Exception ex)
        {
            YmatouLoggingService.Error("YmtUserPasswordChangeEventHandler error， {0}", ex);
        }

        public void Handle(YmtUserPasswordChangeEvent domainEvent)
        {
            LocalServiceLocator.GetService<IYmtUserPasswordChangeEventRepository>().AddAsync(domainEvent);
        }

        public EventHandlerStrategy Strategy
        {
            get { return new EventHandlerStrategy { AsyncReceive = true, TimeOut = TimeSpan.FromSeconds(3) }; }
        }
    }
}
